/*
 * HttpsqsMessageHandler.hpp
 *
 *  Created on: Nov 13, 2011
 *      Author: hao
 */

#ifndef HttpsqsMessageHandler_HPP_
#define HttpsqsMessageHandler_HPP_
#include <xercesc/sax/HandlerBase.hpp>
#include "HttpsqsMessage.hpp"
XERCES_CPP_NAMESPACE_USE
//XERCES_CPP_NAMESPACE_BEGIN
using namespace xercesc;

class HttpsqsMessageHandler : public HandlerBase {
public:
	HttpsqsMessageHandler();
	virtual ~HttpsqsMessageHandler();


	void startDocument();
    void startElement(const XMLCh* const, AttributeList&);
    void endElement(const XMLCh* const);
    void characters(const   XMLCh* const, const unsigned int);
   // void characters(  const   XMLCh* const, const XMLSize_t);
    void fatalError(const SAXParseException&);

    void getHttpsqsMessage(const string);
    string getXMLFromHttpsqsMessage(HttpsqsMessage *httpsqsMessage);

    HttpsqsMessage *getHttpsqsMessage() const;
    void setHttpsqsMessage(HttpsqsMessage *httpsqsMessage);
    //void getHttpsqsMessage(const DocumentHandler*, const string);


private:
    //DocumentHandler* docHandler;
    HttpsqsMessage* httpsqsMessage;
    char* preTag;


};
class XStr
{
public :
    // -----------------------------------------------------------------------
    //  Constructors and Destructor
    // -----------------------------------------------------------------------
    XStr(const char* const toTranscode)
    {
        // Call the private transcoding method
        fUnicodeForm = XMLString::transcode(toTranscode);
    }

    ~XStr()
    {
        XMLString::release(&fUnicodeForm);
    }


    // -----------------------------------------------------------------------
    //  Getter methods
    // -----------------------------------------------------------------------
    const XMLCh* unicodeForm() const
    {
        return fUnicodeForm;
    }

private :
    // -----------------------------------------------------------------------
    //  Private data members
    //
    //  fUnicodeForm
    //      This is the Unicode XMLCh format of the string.
    // -----------------------------------------------------------------------
    XMLCh*   fUnicodeForm;
};

#define X(str) XStr(str).unicodeForm()
#endif /* HttpsqsMessageHandler_HPP_ */
